package daoImpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import dao.BackMessageDao;
import pojo.College;
import pojo.Message;
import utils.DruidUtils;

public class BackMessageDaoImpl implements BackMessageDao{

	@Override
	public ArrayList<Message> getMessage() {
		Connection conn = DruidUtils.getConnection();
		String sql = "select * from message";
		ArrayList<Message> mList = new ArrayList<Message>();
		try {
			PreparedStatement pre = conn.prepareStatement(sql);
			ResultSet res = pre.executeQuery();
			while(res.next()) {
				Message m = new Message();
				m.setMid(res.getInt("mid"));
				m.setmContent(res.getString("mContent"));
				m.setmLoveNum(res.getInt("mLoveNum"));
				m.setmForkNum(res.getInt("mForkNum"));
				m.setmCommentNum(res.getInt("mCommentNum"));
				m.setmReportNum(res.getInt("mReportNum"));
				m.setUserid(res.getInt("userid"));
				mList.add(m);
			}
			res.close();
			pre.close();
			conn.close();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return mList;
	}

}
